// ====================================================
//
// This file is part of the Cscec81 Passport Base Platform.
//
// Create by Cscec81 <support@cscec81.com>
// Copyright (c) 2020-2025 cscec81.com
//
// ====================================================

package com.cscec81.passport.base.commons.concurrent;


import com.cscec81.passport.base.commons.web.SpringContextHolder;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExecutorUtils {

  public static ThreadPoolExecutor getPoll() {
    AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);

    return new ThreadPoolExecutor(
      properties.getCorePoolSize(),
      properties.getMaxPoolSize(),
      properties.getKeepAliveSeconds(),
      TimeUnit.SECONDS,
      new ArrayBlockingQueue<>(properties.getQueueCapacity()),
      new TheadFactoryName()
    );
  }
}
